package cn.tedu.spring.life;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * BeanPostProcessor是Bean的后置处理器，是在Bean对象创建之后对bean进行处理的
 * 其中包含了两个方法:
 * postProcessBeforeInitialization:bean前置处理方法，在初始化之前执行
 * postProcessAfterInitialization:bean后置处理方法，在初始化之后执行
 */
@Component
public class MyBPP implements BeanPostProcessor {
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        System.out.println(beanName);
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        System.out.println(beanName);
        return bean;
    }

}
